home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Util / misc / ChkIndex.lha / ChkIndex / ChkIndex.s < prev    next >
Text File  |  2003-12-26  |  58KB  |  2,053 lines

  1. *****************************************************************************
  2. *                                        *
  3. *    PROGRAM: ChkIndex                            *
  4. *    VERSION: 2.0                                *
  5. *   SOURCE CODE: 48 (22.10.2003)                        *
  6. *       DATE: 22.12.2002 - 20.07.2003                    *
  7. *      LANGUAGE: Assembler (DevPac V3.14)                    *
  8. *     SYSTEM: A1200    KS 40.68 WB 40.42 2MB chip 64MB fast 68030/50mhz    *
  9. *                                        *
  10. *     AUTHOR: Joerg Riemer 14167 Berlin/SchottmuellerStr.107/Germany        *
  11. *      EMAIL: joerg_riemer@freenet.de / mission@cs.tu-berlin.de         *
  12. *                                        *
  13. *    COMMENT: search the aminet index_file for identical entries        *
  14. *                                        *
  15. *      TEMPLATE: INDEXFILE/A      path/name (index)file                *
  16. *         OUTPUTFILE/A     path/name outputfile for equal entries    *
  17. *                                        *
  18. *         WS=WRITESORTED/K save sorted (index)file             *
  19. *         SKIP/N           skip # of lines (index header = 8 lines)  *
  20. *         C=CASE/S         sort case sensitive                *
  21. *         R=REVERSE/S      sort reverse                    *
  22. *         S=SLOW/S         use less memory; save files line by line  *
  23. *                                        *
  24. *     OPTION: To make ChkIndex as short as possible, set BSS_Section     *
  25. *         to NULL and use StripHunk to generate a Code_BSS-segment.  *
  26. *         spares some bytes! but for anybody don't know what this    *
  27. *         means:    "leave it as it is"                    *
  28. *                                         *
  29. *         StripHunk is available at AmiNet dev/misc/...            *
  30. *                                        *
  31. *         for suggestions, hints/tips, and/or questions,            *
  32. *         send an email! (see above for address)                *
  33. *                                        *
  34. *****************************************************************************
  35.  
  36. *        opt    d+
  37. *        opt    o+
  38.  
  39. BSS_Section    set    1
  40.  
  41. *****************************************************************************
  42.  
  43.     output    ram:ChkIndex
  44.  
  45. *****************************************************************************
  46. *
  47. * small statistic (checked while debugging version 1.9.32)
  48. *
  49. * aminet indexfile size: 5.277.715 lines: 71.861 date: 16.3.2003
  50. *
  51. * GetIFile    =  2.017744 sec. (open file; allocmem; read file)
  52. * CreateEList    =  2.613314 sec. (allocmem; create list for all lines)
  53. * SortEList    =  6.436765 sec. (sort list [quicksort])
  54. * GetMEntries   =  3.829775 sec. (search for multiple entries; write lines)
  55. * -----------------------------
  56. *                 14.897598 sec.
  57. * -----------------------------
  58. * WriteSFile    = 14.691603 sec. (write sorted file [line by line])
  59. * -----------------------------
  60. *                 29.589201 sec.
  61. *
  62. ************************************************ exec definitions ***********
  63.  
  64. _LVOOpenLibrary        equ    -552
  65. _LVOCloseLibrary    equ    -414
  66. _LVOAllocMem        equ    -198
  67. _LVOFreeMem        equ    -210
  68. _LVOCopyMem        equ    -624
  69. _LVOCacheClearU        equ    -636
  70.  
  71. ************************************************ dos definitions ************
  72.  
  73. _LVOOutput        equ    -060
  74. _LVOIoErr        equ    -132
  75. _LVOFPutC        equ    -312
  76. _LVOFPuts        equ    -342
  77. _LVOSetIoErr        equ    -462
  78. _LVOPrintFault        equ    -474
  79. _LVOReadArgs        equ    -798
  80. _LVOFreeArgs        equ    -858
  81. _LVOMatchFirst        equ    -822
  82. _LVOMatchNext        equ    -828
  83. _LVOMatchEnd        equ    -834
  84.  
  85. _LVOOpen        equ    -030
  86. _LVOClose        equ    -036
  87. _LVORead        equ    -042
  88. _LVOWrite        equ    -048
  89. _LVODeleteFile        equ    -072
  90. _LVORename        equ    -078
  91. _LVOLock        equ    -084
  92. _LVOUnLock        equ    -090
  93. _LVOCurrentDir        equ    -126
  94. _LVOSetComment        equ    -180
  95. _LVOSetProtection    equ    -186
  96. _LVOFlush        equ    -360
  97. _LVOExamineFH        equ    -390
  98. _LVOCheckSignal        equ    -792
  99. _LVOFilePart        equ    -870
  100. _LVOPutStr        equ    -948
  101. _LVOVPrintf        equ    -954
  102.  
  103. MODE_OLDFILE        equ    1005
  104. MODE_NEWFILE        equ    1006
  105.  
  106. ACCESS_READ        equ    -002
  107.  
  108. fib_DirEntryType    equ    $004
  109. fib_Protection        equ    $074
  110. fib_Size        equ    $07C
  111. fib_Comment        equ    $090
  112. fib_SIZEOF        equ    $104
  113.  
  114. FIBB_ARCHIVE        equ    $004
  115.  
  116. SIGBREAKB_CTRL_C    equ    $00C
  117. SIGBREAKB_CTRL_D    equ    $00D
  118. SIGBREAKB_CTRL_E    equ    $00E
  119. SIGBREAKB_CTRL_F    equ    $00F
  120.  
  121. ************************************************ bss datas ******************
  122.  
  123. FIBlock        rs.b    fib_SIZEOF        ;buffer for fileinfoblock
  124.  
  125. DOSBase        rs.l    1            ;ptr. base of library
  126.  
  127. ArgArray    rs.l    0            ;argarray
  128. IndexFile    rs.l    1            ;ptr. path/name indexfile
  129. OutputFile    rs.l    1            ;ptr. path/name outputfile
  130. SortedFile    rs.l    1            ;ptr. path/name sorted ifile
  131. SkipHead    rs.l    1            ;# of lines to skip
  132. Case        rs.l    1            ;flag sort case sensitive
  133. Reverse        rs.l    1            ;flag sort reverse
  134. Slow        rs.l    1            ;flag (write line by line)
  135.  
  136. RDArgs        rs.l    1            ;returned by readargs
  137. IHandle        rs.l    1            ;handle indexfile
  138. OHandle        rs.l    1            ;handle outputfile
  139. SHandle        rs.l    1            ;handle sorted indexfile
  140. MemoryA        rs.l    1            ;membase indexfile
  141. SkipHM        rs.l    1            ;membase indexfile w/o head
  142. MemoryB        rs.l    1            ;membase sorted indexfile
  143. MSizeB        rs.l    1            ;memsize sorted file w/o head
  144. MemoryC        rs.l    1            ;membase outputfile
  145. MSizeC        rs.l    1            ;memsize outputfile
  146. RCode1        rs.l    1            ;errorcode -> rc
  147. RCode2        rs.l    1            ;errorcode -> result2
  148. Count        rs.l    1            ;# of bytes written out/file
  149. SCount        rs.l    1            ;# of bytes written sort/file
  150. EList        rs.l    1            ;membase entrylist
  151. ELSize        rs.l    1            ;size of entrylist
  152. Lines        rs.l    1            ;# of lines (ifile w/o head)
  153.  
  154. BSS_Size    rs.b    0            ;bss_size over all
  155.  
  156. *****************************************************************************
  157.  
  158. Start        movem.l    D1-D7/A0-A6,-(SP)    ;save registers
  159.  
  160.         ifd    BSS_Section        ;check assembler condition
  161.  
  162.         movea.l    Start-4(pc),A5        ;get bss_section
  163.         addq.l    #1,A5            ;skip pointer (next segment)
  164.         adda.l    A5,A5            ;convert bpcl_pointer
  165.         adda.l    A5,A5            ;to real_address
  166.  
  167.         elseif                ;otherwise
  168.  
  169.         lea    DataBase(pc),A5        ;set data area
  170.  
  171.         endc                ;end condition
  172.  
  173. ************************************************ open required libraries ****
  174.  
  175.         moveq    #20,D0            ;failat level
  176.         move.l    D0,RCode1(A5)        ;preset error (no library)
  177.  
  178.         movea.l    4.w,A6            ;set EXEC to call a function
  179.  
  180.         moveq    #37,D0            ;required library version
  181.         lea    DOSName(pc),A1        ;set library name
  182.         jsr    _LVOOpenLibrary(A6)    ;use EXEC to (openlibrary)
  183.         move.l    D0,DOSBase(A5)        ;save base
  184.  
  185.         beq.b    CloseLibs        ;branch if not open
  186.  
  187. *****************************************************************************
  188.  
  189.         bsr.b    Main
  190.  
  191. ************************************************ close libraries ************
  192.  
  193. CloseLibs    movea.l    4.w,A6            ;set EXEC to call a function
  194.  
  195. CloseDOS    move.l    DOSBase(A5),D1        ;get base_ptr
  196.         beq.b    ExitDOS            ;branch when not open
  197.         movea.l    D1,A1            ;set base_ptr
  198.         jsr    _LVOCloseLibrary(A6)    ;use EXEC to (closelibrary)
  199.  
  200. ExitDOS        move.l    RCode1(A5),D0        ;set returncode
  201.         movem.l    (SP)+,D1-D7/A0-A6    ;restore registers
  202.         rts                ;go back (shell)
  203.  
  204. *****************************************************************************
  205.  
  206. DOSName        dc.b    "dos.library",0
  207.  
  208. *****************************************************************************
  209.  
  210. version    dc.b "$VER: ChkIndex 2.0 48 (22.10.03) by joerg riemer jan'03",0
  211.  
  212. *****************************************************************************
  213.  
  214.         cnop    0,4
  215.  
  216. *****************************************************************************
  217.  
  218. Main        clr.l    RCode1(A5)        ;clear returncode
  219.  
  220. ;-----------------------------------------------
  221.  
  222.         bsr    ReadArgs        ;read user_arguments
  223.         bsr    ChkArgs            ;check "SKIP/N" for wrong #
  224.         bsr.b    ChkReverse        ;sort reverse ?
  225.         bsr    OpenOFile        ;open outputfile
  226.         bsr    OpenSFile        ;open sorted indexfile (new)
  227.         bsr    GetIFile        ;open/read/close indexfile
  228.         bsr    SkipHeader        ;skip headlines
  229.         bsr.b    ChkBreak        ;check for user break
  230.         bsr    CreateEList        ;create entrylist
  231.         bsr.b    ChkBreak        ;check for user break
  232.         bsr    SortEList        ;sort entrylist
  233.         bsr.b    ChkBreak        ;check for user break
  234.         bsr    WriteSFile        ;write/close sorted indexfile
  235.         bsr.b    ChkBreak        ;check for user break
  236.         bsr    GetMEntries        ;search for multiple entries
  237.  
  238. ;-----------------------------------------------
  239.  
  240. Quit        bsr    FreeMemC        ;free memory (outputfile)
  241.         bsr    FreeMemB        ;free memory (sorted ifile)
  242.         bsr    FreeEList        ;free memory (entrylist)
  243.         bsr    FreeMemA        ;free memory (indexfile)
  244.         bsr    CloseSFile        ;close sorted indexfile
  245.         bsr    CloseIFile        ;close indexfile
  246.         bsr    CloseOFile        ;close outputfile
  247.         bsr    FreeArgs        ;free memory (readargs)
  248.         rts                ;go back
  249.  
  250. *****************************************************************************
  251.  
  252.         cnop    0,4
  253.  
  254. *********************************************** check reverse sort **********
  255.  
  256. ChkReverse    tst.w    Reverse(A5)        ;sort reverse ?
  257.         beq.b    .quit            ;no, quit
  258.  
  259.         moveq    #1,D0            ;get switch
  260.  
  261.         lea    SortEList(pc),A0    ;get routine
  262.         move.w    #Patch1,D1        ;get offset patch 1
  263.         eor.b    D0,0(A0,D1.w)        ;flip condition (bcc<->bcs)
  264.         move.w    #Patch2,D1        ;get offset patch 2
  265.         eor.b    D0,0(A0,D1.w)        ;flip condition (bcs<->bcc)
  266.  
  267.         lea    SortEListC(pc),A0    ;get routine
  268.         move.w    #Patch3,D1        ;get offset patch 1
  269.         eor.b    D0,0(A0,D1.w)        ;flip condition (bcc<->bcs)
  270.         move.w    #Patch4,D1        ;get offset patch 2
  271.         eor.b    D0,0(A0,D1.w)        ;flip condition (bcc<->bcs)
  272.  
  273.         movea.l    4.w,A6            ;set EXEC to call a function
  274.         jsr    _LVOCacheClearU(A6)    ;clear cache if available
  275.         
  276. .quit        rts                ;go back
  277.  
  278. *****************************************************************************
  279.  
  280.         cnop    0,4
  281.  
  282. *********************************************** check for break <ctrl><c> ***
  283.  
  284. ChkBreak    moveq    #00,D1            ;prepare signal mask
  285.         bset    #12,D1            ;set break bit (ctrl_c)
  286.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  287.         jsr    _LVOCheckSignal(A6)    ;use DOS to (checksignal)
  288.         btst    #12,D0            ;test break bit (ctrl_c)
  289.         bne    Error3            ;if set, branch (set ioerr)
  290.         rts                ;go back
  291.  
  292. *****************************************************************************
  293.  
  294.         cnop    0,4
  295.  
  296. *********************************************** create list of all lines ****
  297.  
  298. CreateEList    movea.l    SkipHM(A5),A0        ;base of indexfile w/o head
  299.  
  300.         movea.l    A0,A1            ;preset register (size mem_b)
  301. ;-----------------------------------------------
  302.         moveq    #00,D0            ;prepare register
  303.         moveq    #10,D7            ;set linefeed
  304.  
  305. .CalcLines    cmp.b    (A0)+,D7        ;search linefeed
  306.         bne.b    .CalcLines        ;do until
  307.         addq.l    #1,D0            ;inc. number of lines
  308.         tst.b    (A0)            ;check for eof
  309.         bne.b    .CalcLines        ;do until
  310. ;-----------------------------------------------
  311.         suba.l    A1,A0            ;calc. size of memory_b
  312.         move.l    A0,MSizeB(A5)        ;save size (sorted ifile!)
  313. ;-----------------------------------------------
  314.         move.l    D0,Lines(A5)        ;save # of lines
  315.  
  316.         lsl.l    #3,D0            ;need 8 bytes for each line!
  317.  
  318.         addq.l    #8,D0            ;add size for list_terminator
  319.  
  320.         move.l    D0,ELSize(A5)        ;save size
  321.  
  322.         moveq    #0,D1            ;no memory options
  323.  
  324.         movea.l    4.w,A6            ;set EXEC to call a function
  325.         jsr    _LVOAllocMem(A6)    ;use EXEC to (allocmem)
  326.         move.l    D0,EList(A5)        ;save memorybase
  327.         beq    Error2            ;branch if fail (close file)
  328. ;-----------------------------------------------
  329. test        movea.l    SkipHM(A5),A0        ;get indexfile
  330.         movea.l    D0,A1            ;get entrylist
  331.  
  332. .MakeList    move.l    A0,D0            ;reset register
  333.         move.l    A0,(A1)+        ;save base of line (1.long)
  334. .CalcLSize    cmp.b    (A0)+,D7        ;search for linefeed
  335.         bne.b    .CalcLSize        ;do until
  336.         sub.l    A0,D0            ;calc. string length
  337.         neg.l    D0            ;calc. string length
  338.         move.l    D0,(A1)+        ;save length of line (2.long)
  339.         tst.b    (A0)            ;check for eof
  340.         bne.b    .MakeList        ;do until
  341.  
  342.         moveq    #0,D0            ;get terminator
  343.         move.l    D0,(A1)+        ;set list_terminator
  344.         move.l    D0,(A1)            ;set list_terminator
  345.  
  346.         rts                ;go back
  347.  
  348. ******************************************************************************
  349.  
  350.         cnop    0,4
  351.  
  352. *********************************************** quicksort case insensitive **
  353.  
  354. SortEList    movea.l    EList(A5),A0        ;get entrylist
  355.         move.l    Lines(A5),D1        ;get # of lines
  356.         beq    .QuitSort        ;branch if zero
  357.  
  358.         tst.w    Case(A5)
  359.         bne    SortEListC
  360.  
  361.         lea    ChrTab(pc),A6        ;sort case insensitive
  362.  
  363.         moveq    #0,D0            ;init. left
  364.         subq.l    #1,D1            ;init. right
  365.  
  366. .QuickSort:    movem.l    D4-7,-(SP)
  367.  
  368. ************************************************
  369. * le = lo; ri = hi *****************************
  370.  
  371.         move.l    D0,D4            ;left
  372.         move.l    D1,D5            ;right
  373.  
  374.         move.l    D0,D6            ;low
  375.         move.l    D1,D7            ;high
  376.  
  377. ************************************************
  378. * p = (hi+lo)/2 ********************************
  379.  
  380.         move.l    D1,D3            ;get high
  381.         add.l    D0,D3            ;(hi+lo)
  382.         lsr.l    #1,D3            ;(hi+lo)/2
  383.         lsl.l    #3,D3            ;offset for 2 lwords
  384.         move.l    0(A0,D3.l),A3        ;get pivotelement
  385.         move.l    4(A0,D3.l),A4        ;get length of pivotelement
  386.         subq.l    #1,A4            ;dbra!!
  387.  
  388.         moveq    #0,D0
  389.         moveq    #0,D1
  390.  
  391.         bra.b    .le_loop_1
  392.  
  393. ************************************************
  394. * while (f[le] < p) ; le++ *********************
  395.  
  396. .le_loop_2    addq.l    #1,D4            ;le++
  397.  
  398. .le_loop_1    move.l    D4,D3            ;get left_index
  399.         lsl.l    #3,D3            ;prepare offset
  400.         movea.l    0(A0,D3.l),A1        ;get entry to compare
  401.         movea.l    A3,A2            ;set pivotelement
  402.         move.l    A4,D2            ;set length of pivotelement
  403.  
  404. .le_compare    move.b    (A1)+,D0        ;compare entries
  405.         move.b    (A2)+,D1        ;char. by char.
  406.         and.b    0(A6,D0.w),D0        ;force uppercase
  407.         and.b    0(A6,D1.w),D1        ;for both
  408.         cmp.b    D1,D0
  409.         dbne    d2,.le_compare        ;do until end of line
  410. Patch1        equ    *-SortEList
  411.         bcc.b    .ri_loop_1        ;branch if entry > pivot
  412.  
  413.         tst.w    d2            ;entry = pivot ?
  414.         bpl.b    .le_loop_2        ;inc. left_index if not
  415.  
  416. ************************************************
  417.  
  418.         bra.b    .ri_loop_1
  419.  
  420. ************************************************
  421. * while ( p < f[ri]); ri-- *********************
  422.  
  423. .ri_loop_2    subq.l    #1,D5            ;ri--
  424.  
  425. .ri_loop_1    move.l    D5,D3            ;get right_index
  426.         lsl.l    #3,D3            ;prepare offset
  427.         movea.l    0(A0,D3.l),A1        ;get entry to compare
  428.         movea.l    A3,A2            ;set pivotelement
  429.         move.l    A4,D2            ;set length of pivotelement
  430.  
  431. .ri_compare    move.b    (A1)+,D0        ;compare entries
  432.         move.b    (A2)+,D1        ;char. by char.
  433.         and.b    0(A6,D0.w),D0        ;force uppercase
  434.         and.b    0(A6,D1.w),D1        ;for both
  435.         cmp.b    D1,D0
  436.         dbne    d2,.ri_compare        ;do until end of line
  437. Patch2        equ    *-SortEList
  438.         bcs.b    .skip1            ;branch if entry < pivot
  439.  
  440.         tst.w    d2            ;entry = pivot ?
  441.         bpl.b    .ri_loop_2        ;dec. right_index if not
  442.  
  443. ************************************************
  444. * if (le <= ri); swap (f,le,ri); le++; ri-- ****
  445.  
  446. .skip1        cmp.l    D5,D4            ;left<=right ?
  447.         bgt.b    .skip2            ;
  448.         beq.b    .skip3            ;
  449.  
  450.         move.l    D4,D3            ;left
  451.         lsl.l    #3,D3
  452.         movea.l    A0,A1
  453.         adda.l    D3,A1
  454.  
  455.         move.l    D5,D3            ;right
  456.         lsl.l    #3,D3
  457.         movea.l    A0,A2
  458.         adda.l    D3,A2
  459.  
  460.         move.l    (A1),D2            ;swap entry pointers
  461.         move.l    (A2),(A1)+        ;
  462.         move.l    D2,(A2)+        ;
  463.  
  464.         move.l    (A1),D2            ;swap entry_length, too
  465.         move.l    (A2),(A1)        ;
  466.         move.l    D2,(A2)            ;
  467.  
  468. .skip3        addq.l    #1,D4            ;le++
  469.         subq.l    #1,D5            ;ri--
  470.  
  471. ************************************************
  472. * if le <= ri do again *************************
  473.  
  474.         cmp.l    D5,D4            ;right,left
  475.         ble.b    .le_loop_1
  476.  
  477. ************************************************
  478. * if (lo < ri) quicksort (f,lo,ri) *************
  479.  
  480. .skip2        cmp.l    D5,D6            ;right,low
  481.         bge.b    .goon_1
  482.  
  483.         move.l    D6,D0            ;low
  484.         move.l    D5,D1            ;right
  485.         bsr    .QuickSort
  486.  
  487. ************************************************
  488. * if (le < hi) quicksort (f,le,hi) *************
  489.  
  490. .goon_1        cmp.l    D4,D7            ;left,high
  491.         ble.b    .goon_2
  492.  
  493.         move.l    D4,D0            ;left
  494.         move.l    D7,D1            ;high
  495.         bsr    .QuickSort
  496.  
  497. ************************************************
  498.  
  499. .goon_2        movem.l (SP)+,D4-7
  500. .QuitSort    rts
  501.  
  502. *****************************************************************************
  503.  
  504.         cnop    0,4
  505.  
  506. *****************************************************************************
  507.  
  508. ChrTab    dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  509.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  510.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  511.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  512.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  513.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  514.     dc.b $FF,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E,$4F
  515.     dc.b $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5A,$FF,$FF,$FF,$FF,$FF
  516.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  517.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  518.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  519.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  520.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  521.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  522.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  523.     dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
  524.  
  525. ******************************************************************************
  526.  
  527.         cnop    0,4
  528.  
  529. *********************************************** quicksort case sensitive ****
  530.  
  531. SortEListC    moveq    #0,D0            ;init. left
  532.         subq.l    #1,D1            ;init. right (f.length-1)
  533.  
  534. .QuickSort    movem.l    D4-7,-(SP)
  535.  
  536. ************************************************
  537. * le = lo; ri = hi *****************************
  538.  
  539.         move.l    D0,D4            ;left
  540.         move.l    D1,D5            ;right
  541.  
  542.         move.l    D0,D6            ;low
  543.         move.l    D1,D7            ;high
  544.  
  545. ************************************************
  546. * p = (hi+lo)/2 ********************************
  547.  
  548.         move.l    D1,D3            ;get high
  549.         add.l    D0,D3            ;(hi+lo)
  550.         lsr.l    #1,D3            ;(hi+lo)/2
  551.         lsl.l    #3,D3            ;offset for 2 lwords
  552.         move.l    0(A0,D3.l),A3        ;get pivotelement
  553.         move.l    4(A0,D3.l),A4        ;get length of pivotelement
  554.         subq.l    #1,A4            ;dbra!!
  555.  
  556.         bra.b    .le_loop_1
  557.  
  558. ************************************************
  559. * while (f[le] < p) ; le++ *********************
  560.  
  561. .le_loop_2    addq.l    #1,D4            ;le++
  562.  
  563. .le_loop_1    move.l    D4,D3            ;get left_index
  564.         lsl.l    #3,D3            ;prepare offset
  565.         movea.l    0(A0,D3.l),A1        ;get entry to compare
  566.         movea.l    A3,A2            ;set pivotelement
  567.         move.l    A4,D2            ;set length of pivotelement
  568.  
  569. .le_compare    cmp.b    (A2)+,(A1)+        ;compare entries
  570.         dbne    d2,.le_compare        ;do until end of line
  571. Patch3        equ    *-SortEListC
  572.         bcc.b    .ri_loop_1        ;branch if entry > pivot
  573.  
  574.         tst.w    d2            ;entry = pivot ?
  575.         bpl.b    .le_loop_2        ;inc. left_index if not
  576.  
  577. ************************************************
  578.  
  579.         bra.b    .ri_loop_1
  580.  
  581. ************************************************
  582. * while ( p < f[ri]); ri-- *********************
  583.  
  584. .ri_loop_2    subq.l    #1,D5            ;ri--
  585.  
  586. .ri_loop_1    move.l    D5,D3            ;get right_index
  587.         lsl.l    #3,D3            ;prepare offset
  588.         movea.l    0(A0,D3.l),A1        ;get entry to compare
  589.         movea.l    A3,A2            ;set pivotelement
  590.         move.l    A4,D2            ;set length of pivotelement
  591.  
  592. .ri_compare    cmp.b    (A2)+,(A1)+        ;compare entries
  593.         dbne    d2,.ri_compare        ;do until end of line
  594. Patch4        equ    *-SortEListC
  595.         bcs.b    .skip1            ;branch if entry < pivot
  596.  
  597.         tst.w    d2            ;entry = pivot ?
  598.         bpl.b    .ri_loop_2        ;dec. right_index if not
  599.  
  600. ************************************************
  601. * if (le <= ri); swap (f,le,ri); le++; ri-- ****
  602.  
  603. .skip1        cmp.l    D5,D4            ;left<=right ?
  604.         bgt.b    .skip2            ;
  605.         beq.b    .skip3            ;
  606.  
  607.         move.l    D4,D3            ;left
  608.         lsl.l    #3,D3
  609.         movea.l    A0,A1
  610.         adda.l    D3,A1
  611.  
  612.         move.l    D5,D3            ;right
  613.         lsl.l    #3,D3
  614.         movea.l    A0,A2
  615.         adda.l    D3,A2
  616.  
  617.         move.l    (A1),D2            ;swap entry pointers
  618.         move.l    (A2),(A1)+
  619.         move.l    D2,(A2)+
  620.  
  621.         move.l    (A1),D2            ;swap entry_length, too
  622.         move.l    (A2),(A1)
  623.         move.l    D2,(A2)
  624.  
  625. .skip3        addq.l    #1,D4            ;le++
  626.         subq.l    #1,D5            ;ri--
  627.  
  628. ************************************************
  629. * if le <= ri do again *************************
  630.  
  631.         cmp.l    D5,D4            ;right,left
  632.         ble.b    .le_loop_1
  633.  
  634. ************************************************
  635. * if (lo < ri) quicksort (f,lo,ri) *************
  636.  
  637. .skip2        cmp.l    D5,D6            ;right,low
  638.         bge.b    .goon_1
  639.  
  640.         move.l    D6,D0            ;low
  641.         move.l    D5,D1            ;right
  642.         bsr    .QuickSort
  643.  
  644. ************************************************
  645. * if (le < hi) quicksort (f,le,hi) *************
  646.  
  647. .goon_1        cmp.l    D4,D7            ;left,high
  648.         ble.b    .goon_2
  649.  
  650.         move.l    D4,D0            ;left
  651.         move.l    D7,D1            ;high
  652.         bsr    .QuickSort
  653.  
  654. ************************************************
  655.  
  656. .goon_2        movem.l (SP)+,D4-7
  657. .QuitSort    rts
  658.  
  659. *****************************************************************************
  660.  
  661.         cnop    0,4
  662.  
  663. *********************************************** open new file (output) ******
  664.  
  665. OpenOFile    move.l    OutputFile(A5),D1    ;get filename
  666.         beq.b    .quit
  667.         move.l    #MODE_NEWFILE,D2    ;open new file!!
  668.         movea.l    DOSBase(A5),A6        ;set dos_base
  669.         jsr    _LVOOpen(A6)        ;use dos to open file
  670.         move.l    D0,OHandle(A5)        ;save handle
  671.         beq    Error2            ;print error when fail
  672. .quit        rts                ;go back
  673.  
  674. *****************************************************************************
  675.  
  676.         cnop    0,4
  677.  
  678. *********************************************** search for multiple entries *
  679.  
  680. GetMEntries    tst.l    OHandle(A5)        ;save equal entries?
  681.         beq    QuitSearch        ;quit if not set
  682.  
  683.         moveq    #0,D0            ;char. entry_a
  684.         moveq    #0,D1            ;char. entry_b
  685.         moveq    #0,D3            ;length entry_a
  686.         moveq    #0,D5            ;length entry_b
  687.         moveq    #0,D7            ;size outputfile
  688.  
  689.         lea    ChrTab(pc),A6        ;force uppercase
  690.  
  691.         moveq    #1,D6        ;id search_1
  692.         bsr    Search_1    ;filename,path
  693.  
  694.         addq.b    #1,D6        ;id search_2
  695.         bsr    Search_2    ;filename,size,age,description
  696.  
  697.         addq.b    #1,D6        ;id search_3
  698.         bsr    Search_3    ;filename,size,age
  699.  
  700.         addq.b    #1,D6        ;id search_4
  701.         bsr    Search_4    ;filename,size,description
  702.  
  703.         addq.b    #1,D6        ;id search_5
  704.         bsr    Search_5    ;filename,size
  705.  
  706.         addq.b    #1,D6        ;id search_6
  707.         bsr    Search_6    ;filename,age,description
  708.  
  709.         addq.b    #1,D6        ;id search_7
  710.         bsr    Search_7    ;filename,age
  711.  
  712.         addq.b    #1,D6        ;id search_8
  713.         bsr    Search_8    ;filename,description
  714.  
  715.         addq.b    #1,D6        ;id search_9
  716.         bsr    Search_9    ;filename
  717.  
  718. *********************************************** save entries quick **********
  719.  
  720.         tst.w    Slow(A5)
  721.         bne    WriteMELBL
  722.  
  723. ;-----------------------------------------------
  724.         moveq    #8,D0            ;loopcounter
  725.         lea    StrTab(pc),A0        ;get stringtable
  726.  
  727. .AddStrSize    move.l    D0,D1            ;calc. offset
  728.         lsl.w    #3,D1            ;2 lwords
  729.         add.l    4(A0,D1.w),D7        ;add stringlength (1-9)
  730.         dbra    d0,.AddStrSize        ;do for all strings
  731. ;-----------------------------------------------
  732.         move.l    D7,MSizeC(A5)        ;save size
  733.  
  734.         move.l    D7,D0            ;set size
  735.         moveq    #0,D1            ;no memory options
  736.  
  737.         movea.l    4.w,A6            ;set EXEC to call a function
  738.         jsr    _LVOAllocMem(A6)    ;use EXEC to (allocmem)
  739.         move.l    D0,MemoryC(A5)        ;save memorybase
  740.         beq    WriteMELBL        ;if fail, save line by line
  741. ;-----------------------------------------------
  742.         move.l    D0,A3            ;presave destination base
  743.  
  744.         moveq    #0,D6            ;search id
  745.  
  746. .DoAgain    movea.l    A3,A1            ;set destination
  747.  
  748.         move.l    D6,D0            ;cal. index
  749.         lsl.w    #3,D0            ;2 lwords
  750.         lea    StrTab(pc),A0        ;get stringtable
  751.         move.l    0(A0,D0.w),D1        ;get offset_x
  752.         move.l    4(A0,D0.w),D0        ;get stringsize_x
  753.         add.l    D0,A3            ;inc. destination
  754.         add.l    D1,A0            ;get base string_x
  755.  
  756.         bsr.b    CopyMemQ
  757.  
  758.         addq.l    #1,D6            ;prepare id
  759.         move.l    EList(A5),A2        ;get entrylist
  760.  
  761.         subq.l    #8,A2            ;simple avoids bra!
  762.  
  763. .IncListA    addq.l    #8,A2            ;inc. list_a
  764.         tst.l    (A2)            ;check for eol
  765.         beq.b    .skip            ;branch if so
  766. .ChkID        cmp.w    4(A2),D6        ;entry marked?
  767.         bne.b    .IncListA        ;branch if not
  768.  
  769.         move.l    (A2),A0            ;base of entry (source)
  770.         movea.l    A3,A1            ;set destination
  771.         move.w    6(A2),D0        ;get entrysize
  772.         ext.l    D0            ;clear highword
  773.         add.l    D0,A3            ;inc. destination
  774.  
  775.         bsr.b    CopyMemQ
  776.  
  777.         addq.l    #8,A2            ;inc. list_a
  778.         tst.l    (A2)            ;check for end of list
  779.         bne.b    .ChkID            ;continue if not
  780.  
  781. .skip        cmp.b    #9,D6
  782.         bne.b    .DoAgain
  783. ;-----------------------------------------------
  784.         move.l    OHandle(A5),D1        ;set file
  785.         move.l    MemoryC(A5),D2        ;set buffer
  786.         move.l    MSizeC(A5),D3        ;set size
  787.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  788.         jsr    _LVOWrite(A6)        ;write file
  789.  
  790.         tst.l    D0            ;error returned ?
  791.         bmi    Error2            ;branch if so
  792.  
  793.         add.l    D0,Count(A5)        ;inc. byte count
  794.  
  795.         bsr    CloseOFile
  796. ;-----------------------------------------------
  797. FreeMemC    move.l    MSizeC(A5),D0        ;get size memory_b
  798.         beq.b    .quit
  799.  
  800.         move.l    MemoryC(A5),A1        ;get base memory_b
  801.         movea.l    4.w,A6            ;set EXEC to call a function
  802.         jsr    _LVOFreeMem(A6)        ;use EXEC to (freemem)
  803.  
  804.         moveq    #0,D0
  805.         move.l    D0,MSizeC(A5)        ;clear buffer
  806.         move.l    D0,MemoryC(A5)        ;clear buffer
  807.  
  808. .quit        rts
  809.  
  810. *****************************************************************************
  811.  
  812.         cnop    0,4
  813.  
  814. *****************************************************************************
  815. *  CopyMemQuicker 2.8 - (C) 1991-1994 Arthur Hagen                *
  816. *  Parts of code: (C) 1985-1991 Commodore Business Machines Ltd.        *
  817. *  Posted to the Public Domain                            *
  818. *****************************************************************************
  819.  
  820. * cm000.asm start
  821.  
  822. CopyMemQ    moveq    #12,d1
  823.         cmp.l    d1,d0
  824.         bcs.s    tinycpy        ; too small to gain anything
  825.  
  826.         move.w    a0,d1
  827.         lsr.b    #1,d1        ; fastest test for evenness
  828.         bcc.s    evena0
  829.  
  830.         move.b    (a0)+,(a1)+
  831.         subq.l    #1,d0
  832.  
  833. evena0        move.w    a1,d1
  834.         lsr.b    #1,d1
  835.         bcc.s    evenquicker
  836.  
  837.         moveq    #36*3,d1
  838.         cmp.l    d1,d0
  839.         bcs.s    tinycpy
  840.  
  841. * This is tricky!  They said it couldn't be done...
  842. unevcpy        movem.l    a2-a4/d2-d7,-(sp)
  843.         moveq    #32,d1        ; 8 registers of 4 bytes
  844.         move.w    d1,a3
  845.         moveq    #34,d1        ; as above plus 2 "roundoff" bytes
  846.         move.w    d1,a4
  847.         sub.l    d1,d0
  848.         move.l    d0,a2
  849. uloop        movem.l    (a0)+,d0-d7
  850.         rol.l    #8,d0
  851.         rol.l    #8,d1
  852.         rol.l    #8,d2
  853.         rol.l    #8,d3
  854.         rol.l    #8,d4
  855.         rol.l    #8,d5
  856.         rol.l    #8,d6
  857.         rol.l    #8,d7
  858.         move.b    d0,(a1)+
  859.         move.b    d1,d0
  860.         move.b    d2,d1
  861.         move.b    d3,d2
  862.         move.b    d4,d3
  863.         move.b    d5,d4
  864.         move.b    d6,d5
  865.         move.b    d7,d6
  866.         move.b    (a0)+,d7
  867.         movem.l    d0-d7,(a1)
  868.         adda.w    a3,a1
  869.         move.b    (a0)+,(a1)+
  870.         suba.w    a4,a2
  871.         move.l    a2,d0
  872.         bpl.s    uloop
  873.         add.w    a4,d0
  874.         movem.l    (sp)+,a2-a4/d2-d7
  875.         subq.b    #1,d0
  876.         bcs.s    tdone
  877.  
  878. tloop        move.b    (a0)+,(a1)+
  879. tinycpy        dbf    d0,tloop
  880. tdone        rts
  881.  
  882. evenquicker    moveq    #44*2,d1
  883.         cmp.l    d1,d0
  884.         bcs.s    smlmov
  885.         moveq    #44,d1        ; 11 registers of 4 bytes
  886.         sub.l    d1,d0
  887.         movem.l    d2-d7/a2-a6,-(sp)
  888. bigmov        movem.l    (a0)+,d2-d7/a2-a6
  889.         movem.l    d2-d7/a2-a6,(a1)
  890.         adda.w    d1,a1
  891.         sub.l    d1,d0
  892.         bcc.s    bigmov
  893.         add.w    d1,d0
  894.         movem.l    (sp)+,d2-d7/a2-a6
  895.  
  896. smlmov        lsr.w    #1,d0
  897.         beq.s    even01
  898.         bcs.s    sm13
  899.  
  900.         lsr.w    #1,d0
  901.         beq.s    even2
  902.         bcs.s    sm2
  903.  
  904. sm0        subq.w    #1,d0
  905. loop0        move.l    (a0)+,(a1)+
  906.         dbf    d0,loop0
  907. even0        rts
  908.  
  909. sm2        subq.w    #1,d0
  910. loop2        move.l    (a0)+,(a1)+
  911.         dbf    d0,loop2
  912. even2        move.w    (a0),(a1)
  913.         rts
  914.  
  915. sm13        lsr.w    #1,d0
  916.         beq.s    even3
  917.         bcs.s    sm3
  918.  
  919. sm1        subq.w    #1,d0
  920. loop1        move.l    (a0)+,(a1)+
  921.         dbf    d0,loop1
  922. even1        move.b    (a0),(a1)
  923.         rts
  924.  
  925. sm3        subq.w    #1,d0
  926. loop3        move.l    (a0)+,(a1)+
  927.         dbf    d0,loop3
  928.  
  929. even3        move.w    (a0)+,(a1)+
  930.         move.b    (a0),(a1)
  931.         rts
  932.  
  933. even01        bcs.s    even1
  934.         rts
  935.  
  936. * cm000.asm end
  937.  
  938. *****************************************************************************
  939.  
  940.         cnop    0,4
  941.  
  942. ************************************************ save entries line by line **
  943.  
  944. WriteMELBL    moveq    #0,D6            ;search id
  945.         move.l    OHandle(A5),D7        ;get filehandle
  946.         movea.l    DOSBase(A5),A6        ;get dosbase
  947.  
  948. .DoAgain    move.l    D6,D0            ;cal. index
  949.         lsl.w    #3,D0            ;2 lwords
  950.         lea    StrTab(pc),A0        ;get stringtable
  951.         move.l    4(A0,D0.w),D3        ;set (size)
  952.         add.l    0(A0,D0.w),A0        ;get string
  953.         move.l    A0,D2            ;set (buffer)
  954.         move.l    D7,D1            ;set (file)
  955.         jsr    _LVOWrite(A6)        ;use DOS to (write) bytes
  956.  
  957.         tst.l    D0            ;error returned ?
  958.         bmi    Error2            ;branch if so
  959.  
  960.         add.l    D0,Count(A5)        ;inc. byte count
  961.  
  962.         addq.l    #1,D6            ;prepare id
  963.         move.l    EList(A5),A2        ;get entrylist
  964.  
  965.         subq.l    #8,A2            ;simple avoids bra!
  966.  
  967. .IncListA    addq.l    #8,A2            ;inc. list_a
  968.         tst.l    (A2)            ;check for eol
  969.         beq.b    .skip            ;branch if so
  970. .ChkID        cmp.w    4(A2),D6        ;entry marked?
  971.         bne.b    .IncListA        ;branch if not
  972.  
  973.         move.l    (A2),D2            ;set (buffer)
  974.         move.w    6(A2),D3        ;set (size)
  975.         ext.l    D3            ;clear highword
  976.         move.l    D7,D1            ;set (file)
  977.         jsr    _LVOWrite(A6)        ;use DOS to (write) bytes
  978.  
  979.         tst.l    D0            ;error returned ?
  980.         bmi    Error2            ;branch if so
  981.  
  982.         add.l    D0,Count(A5)        ;inc. byte count
  983.  
  984.         addq.l    #8,A2            ;inc. list_a
  985.         tst.l    (A2)            ;check for end of list
  986.         bne.b    .ChkID            ;continue if not
  987.  
  988. .skip        cmp.b    #9,D6
  989.         bne.b    .DoAgain
  990.  
  991. *********************************************** close outputfile ************
  992.  
  993. CloseOFile    move.l    OHandle(A5),D1        ;set filehandle
  994.         beq.b    .quit            ;branch if not set!
  995.  
  996.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  997.         jsr    _LVOClose(A6)        ;use DOS to (close) file
  998.  
  999.         moveq    #0,D0            ;clear filehandle
  1000.         move.l    D0,OHandle(A5)
  1001.  
  1002.         tst.l    Count(A5)        ;some bytes written ?
  1003.         bne.b    .quit            ;branch if so
  1004.  
  1005.         move.l    OutputFile(A5),D1    ;set filename
  1006.         jsr    _LVODeleteFile(A6)    ;use dos to (delete) file
  1007.  
  1008. .quit        rts                ;go back
  1009.  
  1010. *********************************************** search for equal entries ****
  1011.  
  1012. * search FILENAME
  1013.  
  1014. Search_9    movea.l    EList(A5),A2        ;entrylist
  1015.  
  1016.         subq.l    #8,A2            ;simple avoids bra!
  1017.  
  1018. .IncListA    addq.l    #8,A2            ;inc. list_a
  1019.         tst.w    4(A2)            ;test for skip_over
  1020.         bne.b    .IncListA        ;branch if so
  1021.         move.w    6(A2),D3        ;get length_a / check for eol
  1022.         beq    QuitSearch        ;branch if so
  1023.  
  1024.         moveq    #0,D4            ;clr flag (print sourceline)
  1025.         movea.l    A2,A3            ;set list_b
  1026.  
  1027. .IncListB    addq.l    #8,A3            ;inc. list_b
  1028.         tst.w    4(A3)            ;test for skip_over
  1029.         bne.b    .IncListB        ;branch if so
  1030.         move.w    6(A3),D5        ;get length_b / check for eol
  1031.         beq    QuitSearch        ;branch if so
  1032. ;-----------------------------------------------
  1033.         moveq    #18,D2            ;loopcounter
  1034.  
  1035.         movea.l    (A2),A0            ;get filename_field entry (a)
  1036.         movea.l    (A3),A1            ;get filename_field entry (b)
  1037.  
  1038. .Compare_1    move.b    (A0)+,D0        ;compare filenames
  1039.         move.b    (A1)+,D1        ;char. by char.
  1040.         and.b    0(A6,D0.w),D0        ;force uppercase
  1041.         and.b    0(A6,D1.w),D1        ;for both
  1042.         cmp.b    D0,D1            ;compare chars.
  1043.         dbne    D2,.Compare_1        ;do loop as long as equal
  1044.                         ;and counter is positive
  1045.         tst.w    D2            ;found same filenames ?
  1046.         bpl.b    .IncListA        ;branch if not
  1047.  
  1048.         pea    .IncListB(pc)        ;set return_address
  1049.         bra    MarkEntries        ;mark entries
  1050.  
  1051. *****************************************************************************
  1052.  
  1053.         cnop    0,4
  1054.  
  1055. *****************************************************************************
  1056.  
  1057. * search FILENAME, DESCRIPTION
  1058.  
  1059. Search_8    movea.l    EList(A5),A2        ;entrylist
  1060.  
  1061.         subq.l    #8,A2            ;simple avoids bra!
  1062.  
  1063. .IncListA    addq.l    #8,A2            ;inc. list_a
  1064.         tst.w    4(A2)            ;test for skip_over
  1065.         bne.b    .IncListA        ;branch if so
  1066.         move.w    6(A2),D3        ;get length_a / check for eol
  1067.         beq    QuitSearch        ;branch if so
  1068.  
  1069.         moveq    #0,D4            ;clr flag (print sourceline)
  1070.         movea.l    A2,A3            ;set list_b
  1071.  
  1072. .IncListB    addq.l    #8,A3            ;inc. list_b
  1073.         tst.w    4(A3)            ;test for skip_over
  1074.         bne.b    .IncListB        ;branch if so
  1075.         move.w    6(A3),D5        ;get length_b / check for eol
  1076.         beq    QuitSearch        ;branch if so
  1077. ;-----------------------------------------------
  1078.         moveq    #18,D2            ;loopcounter
  1079.  
  1080.         movea.l    (A2),A0            ;get filename_field entry (a)
  1081.         movea.l    (A3),A1            ;get filename_field entry (b)
  1082.  
  1083. .Compare_1    move.b    (A0)+,D0        ;compare filenames
  1084.         move.b    (A1)+,D1        ;char. by char.
  1085.         and.b    0(A6,D0.w),D0        ;force uppercase
  1086.         and.b    0(A6,D1.w),D1        ;for both
  1087.         cmp.b    D0,D1            ;compare chars.
  1088.         dbne    D2,.Compare_1        ;do loop as long as equal
  1089.                         ;and counter is positive
  1090.         tst.w    D2            ;found same filenames ?
  1091.         bpl.b    .IncListA        ;branch if not
  1092. ;-----------------------------------------------
  1093.         moveq    #-39,D2            ;loopcounter
  1094.         add.w    D3,D2            ;calc. length of description
  1095.  
  1096.         lea    19(A0),A0        ;get description_field (a)
  1097.         lea    19(A1),A1        ;get description_field (b)
  1098.  
  1099. .Compare_4    move.b    (A0)+,D0        ;compare file_descriptions
  1100.         move.b    (A1)+,D1        ;char. by char.
  1101.         and.b    0(A6,D0.w),D0        ;force uppercase
  1102.         and.b    0(A6,D1.w),D1        ;for both
  1103.         cmp.b    D0,D1            ;compare chars.
  1104.         dbne    D2,.Compare_4        ;do loop as long as equal
  1105.                         ;and counter is positive
  1106.         tst.w    D2            ;found same description ?
  1107.         bpl.b    .IncListB        ;branch if not
  1108.  
  1109.         pea    .IncListB(pc)        ;set return_address
  1110.         bra    MarkEntries        ;mark entries
  1111.  
  1112. *****************************************************************************
  1113.  
  1114.         cnop    0,4
  1115.  
  1116. *****************************************************************************
  1117.  
  1118. * search FILENAME, AGE
  1119.  
  1120. Search_7    movea.l    EList(A5),A2        ;entrylist
  1121.  
  1122.         subq.l    #8,A2            ;simple avoids bra!
  1123.  
  1124. .IncListA    addq.l    #8,A2            ;inc. list_a
  1125.         tst.w    4(A2)            ;test for skip_over
  1126.         bne.b    .IncListA        ;branch if so
  1127.         move.w    6(A2),D3        ;get length_a / check for eol
  1128.         beq    QuitSearch        ;branch if so
  1129.  
  1130.         moveq    #0,D4            ;clr flag (print sourceline)
  1131.         movea.l    A2,A3            ;set list_b
  1132.  
  1133. .IncListB    addq.l    #8,A3            ;inc. list_b
  1134.         tst.w    4(A3)            ;test for skip_over
  1135.         bne.b    .IncListB        ;branch if so
  1136.         move.w    6(A3),D5        ;get length_b / check for eol
  1137.         beq    QuitSearch        ;branch if so
  1138. ;-----------------------------------------------
  1139.         moveq    #18,D2            ;loopcounter
  1140.  
  1141.         movea.l    (A2),A0            ;get filename_field entry (a)
  1142.         movea.l    (A3),A1            ;get filename_field entry (b)
  1143.  
  1144. .Compare_1    move.b    (A0)+,D0        ;compare filenames
  1145.         move.b    (A1)+,D1        ;char. by char.
  1146.         and.b    0(A6,D0.w),D0        ;force uppercase
  1147.         and.b    0(A6,D1.w),D1        ;for both
  1148.         cmp.b    D0,D1            ;compare chars.
  1149.         dbne    D2,.Compare_1        ;do loop as long as equal
  1150.                         ;and counter is positive
  1151.         tst.w    D2            ;found same filenames ?
  1152.         bpl.b    .IncListA        ;branch if not
  1153. ;-----------------------------------------------
  1154.         moveq    #2,D2            ;loopcounter
  1155.  
  1156.         lea     16(A0),A0        ;get age_field entry (a)
  1157.         lea    16(A1),A1        ;get age_field entry (b)
  1158.  
  1159. .Compare_3    move.b    (A0)+,D0        ;compare filesizes
  1160.         move.b    (A1)+,D1        ;char. by char.
  1161.         and.b    0(A6,D0.w),D0        ;force uppercase
  1162.         and.b    0(A6,D1.w),D1        ;for both
  1163.         cmp.b    D0,D1            ;compare chars.
  1164.         dbne    D2,.Compare_3        ;do loop as long as equal
  1165.                         ;and counter is positive
  1166.         tst.w    D2            ;found equal filesize ?
  1167.         bpl.b    .IncListB        ;branch if not
  1168.  
  1169.         pea    .IncListB(pc)        ;set return_address
  1170.         bra    MarkEntries        ;mark entries
  1171.  
  1172. *****************************************************************************
  1173.  
  1174.         cnop    0,4
  1175.  
  1176. *****************************************************************************
  1177.  
  1178. * search FILENAME, AGE, DESCRIPTION
  1179.  
  1180. Search_6    movea.l    EList(A5),A2        ;entrylist
  1181.  
  1182.         subq.l    #8,A2            ;simple avoids bra!
  1183.  
  1184. .IncListA    addq.l    #8,A2            ;inc. list_a
  1185.         tst.w    4(A2)            ;test for skip_over
  1186.         bne.b    .IncListA        ;branch if so
  1187.         move.w    6(A2),D3        ;get length_a / check for eol
  1188.         beq    QuitSearch        ;branch if so
  1189.  
  1190.         moveq    #0,D4            ;clr flag (print sourceline)
  1191.         movea.l    A2,A3            ;set list_b
  1192.  
  1193. .IncListB    addq.l    #8,A3            ;inc. list_b
  1194.         tst.w    4(A3)            ;test for skip_over
  1195.         bne.b    .IncListB        ;branch if so
  1196.         move.w    6(A3),D5        ;get length_b / check for eol
  1197.         beq    QuitSearch        ;branch if so
  1198. ;-----------------------------------------------
  1199.         moveq    #18,D2            ;loopcounter
  1200.  
  1201.         movea.l    (A2),A0            ;get filename_field entry (a)
  1202.         movea.l    (A3),A1            ;get filename_field entry (b)
  1203.  
  1204. .Compare_1    move.b    (A0)+,D0        ;compare filenames
  1205.         move.b    (A1)+,D1        ;char. by char.
  1206.         and.b    0(A6,D0.w),D0        ;force uppercase
  1207.         and.b    0(A6,D1.w),D1        ;for both
  1208.         cmp.b    D0,D1            ;compare chars.
  1209.         dbne    D2,.Compare_1        ;do loop as long as equal
  1210.                         ;and counter is positive
  1211.         tst.w    D2            ;found same filenames ?
  1212.         bpl.b    .IncListA        ;branch if not
  1213. ;-----------------------------------------------
  1214.         moveq    #2,D2            ;loopcounter
  1215.  
  1216.         lea     16(A0),A0        ;get age_field entry (a)
  1217.         lea    16(A1),A1        ;get age_field entry (b)
  1218.  
  1219. .Compare_3    move.b    (A0)+,D0        ;compare filesizes
  1220.         move.b    (A1)+,D1        ;char. by char.
  1221.         and.b    0(A6,D0.w),D0        ;force uppercase
  1222.         and.b    0(A6,D1.w),D1        ;for both
  1223.         cmp.b    D0,D1            ;compare chars.
  1224.         dbne    D2,.Compare_3        ;do loop as long as equal
  1225.                         ;and counter is positive
  1226.         tst.w    D2            ;found equal filesize ?
  1227.         bpl.b    .IncListB        ;branch if not
  1228. ;-----------------------------------------------
  1229.         moveq    #-39,D2            ;loopcounter
  1230.         add.w    D3,D2            ;calc. length of description
  1231.  
  1232. .Compare_4    move.b    (A0)+,D0        ;compare file_descriptions
  1233.         move.b    (A1)+,D1        ;char. by char.
  1234.         and.b    0(A6,D0.w),D0        ;force uppercase
  1235.         and.b    0(A6,D1.w),D1        ;for both
  1236.         cmp.b    D0,D1            ;compare chars.
  1237.         dbne    D2,.Compare_4        ;do loop as long as equal
  1238.                         ;and counter is positive
  1239.         tst.w    D2            ;found same description ?
  1240.         bpl.b    .IncListB        ;branch if not
  1241.  
  1242.         pea    .IncListB(pc)        ;set return_address
  1243.         bra    MarkEntries        ;mark entries
  1244.  
  1245. *****************************************************************************
  1246.  
  1247.         cnop    0,4
  1248.  
  1249. *****************************************************************************
  1250.  
  1251. * search FILENAME, SIZE
  1252.  
  1253. Search_5    movea.l    EList(A5),A2        ;entrylist
  1254.  
  1255.         subq.l    #8,A2            ;simple avoids bra!
  1256.  
  1257. .IncListA    addq.l    #8,A2            ;inc. list_a
  1258.         tst.w    4(A2)            ;test for skip_over
  1259.         bne.b    .IncListA        ;branch if so
  1260.         move.w    6(A2),D3        ;get length_a / check for eol
  1261.         beq    QuitSearch        ;branch if so
  1262.  
  1263.         moveq    #0,D4            ;clr flag (print sourceline)
  1264.         movea.l    A2,A3            ;set list_b
  1265.  
  1266. .IncListB    addq.l    #8,A3            ;inc. list_b
  1267.         tst.w    4(A3)            ;test for skip_over
  1268.         bne.b    .IncListB        ;branch if so
  1269.         move.w    6(A3),D5        ;get length_b / check for eol
  1270.         beq    QuitSearch        ;branch if so
  1271. ;-----------------------------------------------
  1272.         moveq    #18,D2            ;loopcounter
  1273.  
  1274.         movea.l    (A2),A0            ;get filename_field entry (a)
  1275.         movea.l    (A3),A1            ;get filename_field entry (b)
  1276.  
  1277. .Compare_1    move.b    (A0)+,D0        ;compare filenames
  1278.         move.b    (A1)+,D1        ;char. by char.
  1279.         and.b    0(A6,D0.w),D0        ;force uppercase
  1280.         and.b    0(A6,D1.w),D1        ;for both
  1281.         cmp.b    D0,D1            ;compare chars.
  1282.         dbne    D2,.Compare_1        ;do loop as long as equal
  1283.                         ;and counter is positive
  1284.         tst.w    D2            ;found same filenames ?
  1285.         bpl.b    .IncListA        ;branch if not
  1286. ;-----------------------------------------------
  1287.         moveq    #4,D2            ;loopcounter
  1288.  
  1289.         lea     11(A0),A0        ;get size_field entry (a)
  1290.         lea    11(A1),A1        ;get size_field entry (b)
  1291.  
  1292. .Compare_2    move.b    (A0)+,D0        ;compare filesizes
  1293.         move.b    (A1)+,D1        ;char. by char.
  1294.         and.b    0(A6,D0.w),D0        ;force uppercase
  1295.         and.b    0(A6,D1.w),D1        ;for both
  1296.         cmp.b    D0,D1            ;compare chars.
  1297.         dbne    D2,.Compare_2        ;do loop as long as equal
  1298.                         ;and counter is positive
  1299.         tst.w    D2            ;found equal filesize ?
  1300.         bpl.b    .IncListB        ;branch if not
  1301.  
  1302.         pea    .IncListB(pc)        ;set return_address
  1303.         bra    MarkEntries        ;mark entries
  1304.  
  1305. *****************************************************************************
  1306.  
  1307.         cnop    0,4
  1308.  
  1309. *****************************************************************************
  1310.  
  1311. * search FILENAME, SIZE, DESCRIPTION
  1312.  
  1313. Search_4    movea.l    EList(A5),A2        ;entrylist
  1314.  
  1315.         subq.l    #8,A2            ;simple avoids bra!
  1316.  
  1317. .IncListA    addq.l    #8,A2            ;inc. list_a
  1318.         tst.w    4(A2)            ;test for skip_over
  1319.         bne.b    .IncListA        ;branch if so
  1320.         move.w    6(A2),D3        ;get length_a / check for eol
  1321.         beq    QuitSearch        ;branch if so
  1322.  
  1323.         moveq    #0,D4            ;clr flag (print sourceline)
  1324.         movea.l    A2,A3            ;set list_b
  1325.  
  1326. .IncListB    addq.l    #8,A3            ;inc. list_b
  1327.         tst.w    4(A3)            ;test for skip_over
  1328.         bne.b    .IncListB        ;branch if so
  1329.         move.w    6(A3),D5        ;get length_b / check for eol
  1330.         beq    QuitSearch        ;branch if so
  1331. ;-----------------------------------------------
  1332.         moveq    #18,D2            ;loopcounter
  1333.  
  1334.         movea.l    (A2),A0            ;get filename_field entry (a)
  1335.         movea.l    (A3),A1            ;get filename_field entry (b)
  1336.  
  1337. .Compare_1    move.b    (A0)+,D0        ;compare filenames
  1338.         move.b    (A1)+,D1        ;char. by char.
  1339.         and.b    0(A6,D0.w),D0        ;force uppercase
  1340.         and.b    0(A6,D1.w),D1        ;for both
  1341.         cmp.b    D0,D1            ;compare chars.
  1342.         dbne    D2,.Compare_1        ;do loop as long as equal
  1343.                         ;and counter is positive
  1344.         tst.w    D2            ;found same filenames ?
  1345.         bpl.b    .IncListA        ;branch if not
  1346. ;-----------------------------------------------
  1347.         moveq    #4,D2            ;loopcounter
  1348.  
  1349.         lea     11(A0),A0        ;get size_field entry (a)
  1350.         lea    11(A1),A1        ;get size_field entry (b)
  1351.  
  1352. .Compare_2    move.b    (A0)+,D0        ;compare filesizes
  1353.         move.b    (A1)+,D1        ;char. by char.
  1354.         and.b    0(A6,D0.w),D0        ;force uppercase
  1355.         and.b    0(A6,D1.w),D1        ;for both
  1356.         cmp.b    D0,D1            ;compare chars.
  1357.         dbne    D2,.Compare_2        ;do loop as long as equal
  1358.                         ;and counter is positive
  1359.         tst.w    D2            ;found equal filesize ?
  1360.         bpl.b    .IncListB        ;branch if not
  1361. ;-----------------------------------------------
  1362.         moveq    #-39,D2            ;loopcounter
  1363.         add.w    D3,D2            ;calc. length of description
  1364.  
  1365.         addq    #3,A0            ;get description_field (a)
  1366.         addq    #3,A1            ;get description_field (b)
  1367.  
  1368. .Compare_4    move.b    (A0)+,D0        ;compare file_descriptions
  1369.         move.b    (A1)+,D1        ;char. by char.
  1370.         and.b    0(A6,D0.w),D0        ;force uppercase
  1371.         and.b    0(A6,D1.w),D1        ;for both
  1372.         cmp.b    D0,D1            ;compare chars.
  1373.         dbne    D2,.Compare_4        ;do loop as long as equal
  1374.                         ;and counter is positive
  1375.         tst.w    D2            ;found same description ?
  1376.         bpl.b    .IncListB        ;branch if not
  1377.  
  1378.         pea    .IncListB(pc)        ;set return_address
  1379.         bra    MarkEntries        ;mark entries
  1380.  
  1381. *****************************************************************************
  1382.  
  1383.         cnop    0,4
  1384.  
  1385. *****************************************************************************
  1386.  
  1387. * search FILENAME, SIZE, AGE
  1388.  
  1389. Search_3    movea.l    EList(A5),A2        ;entrylist
  1390.  
  1391.         subq.l    #8,A2            ;simple avoids bra!
  1392.  
  1393. .IncListA    addq.l    #8,A2            ;inc. list_a
  1394.         tst.w    4(A2)            ;test for skip_over
  1395.         bne.b    .IncListA        ;branch if so
  1396.         move.w    6(A2),D3        ;get length_a / check for eol
  1397.         beq    QuitSearch        ;branch if so
  1398.  
  1399.         moveq    #0,D4            ;clr flag (print sourceline)
  1400.         movea.l    A2,A3            ;set list_b
  1401.  
  1402. .IncListB    addq.l    #8,A3            ;inc. list_b
  1403.         tst.w    4(A3)            ;test for skip_over
  1404.         bne.b    .IncListB        ;branch if so
  1405.         move.w    6(A3),D5        ;get length_b / check for eol
  1406.         beq    QuitSearch        ;branch if so
  1407. ;-----------------------------------------------
  1408.         moveq    #18,D2            ;loopcounter
  1409.  
  1410.         movea.l    (A2),A0            ;get filename_field entry (a)
  1411.         movea.l    (A3),A1            ;get filename_field entry (b)
  1412.  
  1413. .Compare_1    move.b    (A0)+,D0        ;compare filenames
  1414.         move.b    (A1)+,D1        ;char. by char.
  1415.         and.b    0(A6,D0.w),D0        ;force uppercase
  1416.         and.b    0(A6,D1.w),D1        ;for both
  1417.         cmp.b    D0,D1            ;compare chars.
  1418.         dbne    D2,.Compare_1        ;do loop as long as equal
  1419.                         ;and counter is positive
  1420.         tst.w    D2            ;found same filenames ?
  1421.         bpl.b    .IncListA        ;branch if not
  1422. ;-----------------------------------------------
  1423.         moveq    #4,D2            ;loopcounter
  1424.  
  1425.         lea     11(A0),A0        ;get size_field entry (a)
  1426.         lea    11(A1),A1        ;get size_field entry (b)
  1427.  
  1428. .Compare_2    move.b    (A0)+,D0        ;compare filesizes
  1429.         move.b    (A1)+,D1        ;char. by char.
  1430.         and.b    0(A6,D0.w),D0        ;force uppercase
  1431.         and.b    0(A6,D1.w),D1        ;for both
  1432.         cmp.b    D0,D1            ;compare chars.
  1433.         dbne    D2,.Compare_2        ;do loop as long as equal
  1434.                         ;and counter is positive
  1435.         tst.w    D2            ;found equal filesize ?
  1436.         bpl.b    .IncListB        ;branch if not
  1437. ;-----------------------------------------------
  1438.         moveq    #2,D2            ;loopcounter
  1439.  
  1440. .Compare_3    move.b    (A0)+,D0        ;compare fileages
  1441.         move.b    (A1)+,D1        ;char. by char.
  1442.         and.b    0(A6,D0.w),D0        ;force uppercase
  1443.         and.b    0(A6,D1.w),D1        ;for both
  1444.         cmp.b    D0,D1            ;compare chars.
  1445.         dbne    D2,.Compare_3        ;do loop as long as equal
  1446.                         ;and counter is positive
  1447.         tst.w    D2            ;found equal filesize ?
  1448.         bpl.b    .IncListB        ;branch if not
  1449.  
  1450.         pea    .IncListB(pc)        ;set return_address
  1451.         bra    MarkEntries        ;mark entries
  1452.  
  1453. *****************************************************************************
  1454.  
  1455.         cnop    0,4
  1456.  
  1457. *****************************************************************************
  1458.  
  1459. * search FILENAME, SIZE, AGE, DESCRIPTION
  1460.  
  1461. Search_2    movea.l    EList(A5),A2        ;entrylist
  1462.  
  1463.         subq.l    #8,A2            ;simple avoids bra!
  1464.  
  1465. .IncListA    addq.l    #8,A2            ;inc. list_a
  1466.         tst.w    4(A2)            ;test for skip_over
  1467.         bne.b    .IncListA        ;branch if so
  1468.         move.w    6(A2),D3        ;get length / check for eol
  1469.         beq    QuitSearch        ;branch if so
  1470.  
  1471.         moveq    #0,D4            ;clr flag (print sourceline)
  1472.         movea.l    A2,A3            ;set list_b
  1473.  
  1474. .IncListB    addq.l    #8,A3            ;inc. list_b
  1475.         tst.w    4(A3)            ;test for skip_over
  1476.         bne.b    .IncListB        ;branch if so
  1477.         move.w    6(A3),D5        ;get length_b / check for eol
  1478.         beq    QuitSearch        ;branch if so
  1479. ;-----------------------------------------------
  1480.         moveq    #18,D2            ;loopcounter
  1481.  
  1482.         movea.l    (A2),A0            ;get filename_field entry (a)
  1483.         movea.l    (A3),A1            ;get filename_field entry (b)
  1484.  
  1485. .Compare_1    move.b    (A0)+,D0        ;compare filenames
  1486.         move.b    (A1)+,D1        ;char. by char.
  1487.         and.b    0(A6,D0.w),D0        ;force uppercase
  1488.         and.b    0(A6,D1.w),D1        ;for both
  1489.         cmp.b    D0,D1            ;compare chars.
  1490.         dbne    D2,.Compare_1        ;do loop as long as equal
  1491.                         ;and counter is positive
  1492.         tst.w    D2            ;found same filenames ?
  1493.         bpl.b    .IncListA        ;branch if not
  1494. ;-----------------------------------------------
  1495.         moveq    #4,D2            ;loopcounter
  1496.  
  1497.         lea     11(A0),A0        ;get size_field entry (a)
  1498.         lea    11(A1),A1        ;get size_field entry (b)
  1499.  
  1500. .Compare_2    move.b    (A0)+,D0        ;compare filesizes
  1501.         move.b    (A1)+,D1        ;char. by char.
  1502.         and.b    0(A6,D0.w),D0        ;force uppercase
  1503.         and.b    0(A6,D1.w),D1        ;for both
  1504.         cmp.b    D0,D1            ;compare chars.
  1505.         dbne    D2,.Compare_2        ;do loop as long as equal
  1506.                         ;and counter is positive
  1507.         tst.w    D2            ;found equal filesize ?
  1508.         bpl.b    .IncListB        ;branch if not
  1509. ;-----------------------------------------------
  1510.         moveq    #2,D2            ;loopcounter
  1511.  
  1512. .Compare_3    move.b    (A0)+,D0        ;compare fileages
  1513.         move.b    (A1)+,D1        ;char. by char.
  1514.         and.b    0(A6,D0.w),D0        ;force uppercase
  1515.         and.b    0(A6,D1.w),D1        ;for both
  1516.         cmp.b    D0,D1            ;compare chars.
  1517.         dbne    D2,.Compare_3        ;do loop as long as equal
  1518.                         ;and counter is positive
  1519.         tst.w    D2            ;found equal filesize ?
  1520.         bpl.b    .IncListB        ;branch if not
  1521. ;-----------------------------------------------
  1522.         moveq    #-39,D2            ;loopcounter
  1523.         add.w    D3,D2            ;calc. length of description
  1524.  
  1525. .Compare_4    move.b    (A0)+,D0        ;compare file_descriptions
  1526.         move.b    (A1)+,D1        ;char. by char.
  1527.         and.b    0(A6,D0.w),D0        ;force uppercase
  1528.         and.b    0(A6,D1.w),D1        ;for both
  1529.         cmp.b    D0,D1            ;compare chars.
  1530.         dbne    D2,.Compare_4        ;do loop as long as equal
  1531.                         ;and counter is positive
  1532.         tst.w    D2            ;found same description ?
  1533.         bpl.b    .IncListB        ;branch if not
  1534.  
  1535.         pea    .IncListB(pc)        ;set return_address
  1536.         bra.b    MarkEntries        ;mark entries
  1537.  
  1538. *****************************************************************************
  1539.  
  1540.         cnop    0,4
  1541.  
  1542. *****************************************************************************
  1543.  
  1544. * search FILENAME, PATH
  1545.  
  1546. Search_1    movea.l    EList(A5),A2        ;entrylist
  1547.  
  1548.         subq.l    #8,A2            ;simple avoids bra!
  1549.  
  1550. .IncListA    addq.l    #8,A2            ;inc. list_a
  1551.         tst.w    4(A2)            ;test for skip_over
  1552.         bne.b    .IncListA        ;branch if so
  1553.         move.w    6(A2),D3        ;get length_a / check for eol
  1554.         beq.b    QuitSearch        ;branch if so
  1555.  
  1556.         moveq    #0,D4            ;clr flag (print sourceline)
  1557.         movea.l    A2,A3            ;set list_b
  1558.  
  1559. .IncListB    addq.l    #8,A3            ;inc. list_b
  1560.         tst.w    4(A3)            ;test for skip_over
  1561.         bne.b    .IncListB        ;branch if so
  1562.         move.w    6(A3),D5        ;get length_b / check for eol
  1563.         beq.b    QuitSearch        ;branch if so
  1564. ;-----------------------------------------------
  1565.         moveq    #29,D2            ;loopcounter
  1566.  
  1567.         movea.l    (A2),A0            ;get filename_field entry (a)
  1568.         movea.l    (A3),A1            ;get filename_field entry (b)
  1569.  
  1570. .Compare_1    move.b    (A0)+,D0        ;compare filenames
  1571.         move.b    (A1)+,D1        ;char. by char.
  1572.         and.b    0(A6,D0.w),D0        ;force uppercase
  1573.         and.b    0(A6,D1.w),D1        ;for both
  1574.         cmp.b    D0,D1            ;compare chars.
  1575.         dbne    D2,.Compare_1        ;do loop as long as equal
  1576.                         ;and counter is positive
  1577.         tst.w    D2            ;found same filenames ?
  1578.         bpl.b    .IncListA        ;branch if not
  1579.  
  1580.         pea    .IncListB(pc)        ;set return_address
  1581.  
  1582. *****************************************************************************
  1583.  
  1584. MarkEntries    tst.b    D4            ;mark entry (a) ?
  1585.         bne.b    .MarkEntry_b        ;no, entry (b) only!
  1586.  
  1587.         moveq    #1,D4            ;flag, entry (a) marked!
  1588.  
  1589. .MarkEntry_a    add.l    D3,D7            ;inc. me_memory size
  1590.         move.w    D6,4(A2)        ;set flag (skip_over)
  1591.  
  1592. .MarkEntry_b    add.l    D5,D7            ;inc. me_memory size
  1593.         move.w    D6,4(A3)        ;set flag (skip_over)
  1594.  
  1595. QuitSearch    rts                ;quit search (equal)
  1596.  
  1597. *****************************************************************************
  1598.  
  1599.         cnop    0,4
  1600.  
  1601. *****************************************************************************
  1602.  
  1603. StrTab    dc.l    String1-StrTab,S1Size
  1604.     dc.l    String2-StrTab,S2Size
  1605.     dc.l    String3-StrTab,S3Size
  1606.     dc.l    String4-StrTab,S4Size
  1607.     dc.l    String5-StrTab,S5Size
  1608.     dc.l    String6-StrTab,S6Size
  1609.     dc.l    String7-StrTab,S7Size
  1610.     dc.l    String8-StrTab,S8Size
  1611.     dc.l    String9-StrTab,S9Size
  1612.  
  1613. *****************************************************************************
  1614.  
  1615. String1    dc.b $A," ** entries - including same FILENAME; PATH",$A,$A
  1616. S1Size    equ *-String1
  1617.     even
  1618.  
  1619. String2    dc.b $A," ** entries - including same FILENAME; SIZE; AGE; DESCRIPTION",$A,$A
  1620. S2Size    equ *-String2
  1621.     even
  1622.  
  1623. String3    dc.b $A," ** entries - including same FILENAME; SIZE; AGE",$A,$A
  1624. S3Size    equ *-String3
  1625.     even
  1626.  
  1627. String4    dc.b $A," ** entries - including same FILENAME; SIZE; DESCRIPTION",$A,$A
  1628. S4Size    equ *-String4
  1629.     even
  1630.  
  1631. String5    dc.b $A," ** entries - including same FILENAME; SIZE",$A,$A
  1632. S5Size    equ *-String5
  1633.     even
  1634.  
  1635. String6    dc.b $A," ** entries - including same FILENAME; AGE; DESCRIPTION",$A,$A
  1636. S6Size    equ *-String6
  1637.     even
  1638.  
  1639. String7    dc.b $A," ** entries - including same FILENAME; AGE",$A,$A
  1640. S7Size    equ *-String7
  1641.     even
  1642.  
  1643. String8    dc.b $A," ** entries - including same FILENAME; DESCRIPTION",$A,$A
  1644. S8Size    equ *-String8
  1645.     even
  1646.  
  1647. String9    dc.b $A," ** entries - including same FILENAME",$A,$A
  1648. S9Size    equ *-String9
  1649.     even
  1650.  
  1651. *****************************************************************************
  1652.  
  1653.         cnop    0,4
  1654.  
  1655. *********************************************** skip headlines **************
  1656.  
  1657. SkipHeader    movea.l    MemoryA(A5),A0        ;get base of file
  1658.  
  1659.         move.l    SkipHead(A5),D1        ;skip some lines?
  1660.         beq.b    .quit            ;no, quit
  1661.  
  1662.         movea.l    D1,A1            ;get buffer 'skiphead value'
  1663.         move.l    (A1),D0            ;set count
  1664.         beq.b    .quit            ;branch if zero
  1665.  
  1666.         moveq    #0,D1
  1667.         move.b    #219,D1            ;preset "seek error..."
  1668.  
  1669.         moveq    #10,D2            ;linefeed
  1670.  
  1671. .search        cmp.b    (A0)+,D2        ;search linefeed
  1672.         bne.b    .search            ;do until
  1673.  
  1674.         tst.b    (A0)            ;check for eof
  1675.         beq    Error1            ;branch if so!
  1676.  
  1677.         subq.l    #1,D0            ;dec. counter
  1678.         bne.b    .search            ;do until zero
  1679.  
  1680. .quit        move.l    A0,SkipHM(A5)        ;set new base of file
  1681.         rts                ;go back
  1682.  
  1683. *****************************************************************************
  1684.  
  1685.         cnop    0,4
  1686.  
  1687. *********************************************** open new file (sorted) ******
  1688.  
  1689. OpenSFile    move.l    SortedFile(A5),D1    ;get filename
  1690.         beq.b    .quit            ;branch if not given
  1691.         move.l    #MODE_NEWFILE,D2    ;open new file
  1692.         movea.l    DOSBase(A5),A6        ;set dos_base
  1693.         jsr    _LVOOpen(A6)        ;use dos to open file
  1694.         move.l    D0,SHandle(A5)        ;save handle
  1695.         beq    Error2            ;branch if fail
  1696. .quit        rts                ;go back
  1697.  
  1698. *****************************************************************************
  1699.  
  1700.         cnop    0,4
  1701.  
  1702. *********************************************** save new file quick *********
  1703.  
  1704. WriteSFile    move.l    SHandle(A5),D7        ;get filehandle
  1705.         beq    QuitSFile        ;quit if not set
  1706. ;-----------------------------------------------
  1707.         tst.w    Slow(A5)
  1708.         bne.b    WriteSFLBL
  1709. ;-----------------------------------------------
  1710.         move.l    MSizeB(A5),D0        ;get size
  1711.         moveq    #0,D1            ;no memory options
  1712.  
  1713.         movea.l    4.w,A6            ;set EXEC to call a function
  1714.         jsr    _LVOAllocMem(A6)    ;use EXEC to (allocmem)
  1715.         move.l    D0,MemoryB(A5)        ;save memorybase
  1716.         beq.b    WriteSFLBL        ;if fail, save line by line
  1717. ;-----------------------------------------------
  1718.         move.l    D0,A3            ;set memorybase
  1719.         move.l    EList(A5),A2        ;get entrylist
  1720.  
  1721.         move.l    (A2)+,A0        ;base of entry
  1722.         move.l    (A2),D0            ;set size
  1723. .copymem    move.l    A3,A1            ;set destination
  1724.  
  1725.         bsr    CopyMemQ
  1726.  
  1727.         add.l    (A2)+,A3        ;inc. destination
  1728.         move.l    (A2)+,A0        ;set next entry
  1729.         move.l    (A2),D0            ;set size, too
  1730.         bne.b    .copymem        ;do until eol
  1731. ;-----------------------------------------------
  1732.         move.l    D7,D1            ;set file
  1733.         move.l    MemoryB(A5),D2        ;set buffer
  1734.         move.l    MSizeB(A5),D3        ;set size
  1735.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  1736.         jsr    _LVOWrite(A6)        ;write file (line by line)
  1737.  
  1738.         tst.l    D0            ;error returned ?
  1739.         bmi    Error2            ;branch if so
  1740.  
  1741.         add.l    D0,SCount(A5)        ;inc. byte count
  1742.  
  1743.         bsr.b    CloseSFile
  1744. ;-----------------------------------------------
  1745. FreeMemB    move.l    MSizeB(A5),D0        ;get size memory_b
  1746.         beq.b    .quit
  1747.  
  1748.         move.l    MemoryB(A5),A1        ;get base memory_b
  1749.         movea.l    4.w,A6            ;set EXEC to call a function
  1750.         jsr    _LVOFreeMem(A6)        ;use EXEC to (freemem)
  1751.  
  1752.         moveq    #0,D0            ;clear register
  1753.         move.l    D0,MSizeB(A5)        ;clear buffer
  1754.         move.l    D0,MemoryB(A5)        ;clear buffer
  1755.  
  1756. .quit        rts                ;go back
  1757.  
  1758. *****************************************************************************
  1759.  
  1760.         cnop    0,4
  1761.  
  1762. *********************************************** save new file line by line **
  1763.  
  1764. WriteSFLBL    move.l    Lines(A5),D6        ;get # of lines
  1765.         movea.l    EList(A5),A2        ;get entrylist
  1766.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  1767.  
  1768. .WriteLine    move.l    D7,D1            ;set file
  1769.         move.l    (A2)+,D2        ;set buffer
  1770.         move.l    (A2)+,D3        ;set size
  1771.         jsr    _LVOWrite(A6)        ;write file (line by line)
  1772.  
  1773.         tst.l    D0            ;error returned ?
  1774.         bmi    Error2            ;branch if so
  1775.  
  1776.         add.l    D0,SCount(A5)        ;inc. byte count
  1777.  
  1778.         subq.l    #1,D6            ;dec. line count
  1779.         bne.b    .WriteLine        ;do for all lines
  1780.  
  1781. *********************************************** close new file (sorted) *****
  1782.  
  1783. CloseSFile    move.l    SHandle(A5),D1        ;set filehandle
  1784.         beq.b    QuitSFile        ;branch if not given
  1785.  
  1786.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  1787.         jsr    _LVOClose(A6)        ;use DOS to (close) file
  1788.  
  1789.         moveq    #0,D0            ;clear filehandle
  1790.         move.l    D0,SHandle(A5)
  1791.  
  1792.         tst.l    SCount(A5)        ;some bytes written ?
  1793.         bne.b    QuitSFile        ;branch if so
  1794.  
  1795.         move.l    SortedFile(A5),D1    ;set filename
  1796.         jsr    _LVODeleteFile(A6)    ;use dos to (delete) file
  1797.  
  1798. QuitSFile    rts                ;go back
  1799.  
  1800. *****************************************************************************
  1801.  
  1802.         cnop    0,4
  1803.  
  1804. *********************************************** examine; read indexfile *****
  1805.  
  1806. GetIFile    move.l    IndexFile(A5),D1    ;get filename
  1807.         move.l    #MODE_OLDFILE,D2    ;file exists!
  1808.         movea.l    DOSBase(A5),A6        ;set dos_base
  1809.         jsr    _LVOOpen(A6)        ;use dos to open file
  1810.         move.l    D0,IHandle(A5)        ;save filehandle
  1811.         beq    Error2            ;branch if not found
  1812. ;-----------------------------------------------
  1813.         move.l    IHandle(A5),D1        ;set filehandle
  1814.         lea    (A5),A3            ;get buffer for FIB
  1815.         move.l    A3,D2            ;set FileInfoBlock
  1816.         jsr    _LVOExamineFH(A6)    ;use DOS to (examinefh)
  1817.         tst.l    D0            ;test for success
  1818.         beq    Error2            ;branch if not (close file)
  1819. ;-----------------------------------------------
  1820.         move.w    #205,D1            ;preset rcode "not found.."
  1821.         ext.l    D1            ;clear highword
  1822.  
  1823.         move.l    fib_Size(A3),D0        ;set filesize
  1824.         beq    Error1            ;empty file?...
  1825.  
  1826.         addq.l    #2,D0            ;need one linefeed +
  1827.                         ;null terminator at eof
  1828.         addq.l    #3,D0            ;get long aligned
  1829.         andi.b    #-4,D0            ;get long aligned
  1830.  
  1831.         addq.l    #4,D0            ;add room for security ID
  1832.  
  1833.         moveq    #0,D1            ;no options
  1834.  
  1835.         movea.l    4.w,A6            ;set EXEC to call a function
  1836.         jsr    _LVOAllocMem(A6)    ;use EXEC to (allocmem)
  1837.         move.l    D0,MemoryA(A5)        ;save memorybase
  1838.         beq    Error2            ;branch if fail (close file)
  1839. ;----------------------------------------------------------------------------
  1840.         move.l    IHandle(A5),D1        ;set filehandle (read)
  1841.         movea.l    MemoryA(A5),A2        ;get membase (endmark)
  1842.         move.l    A2,D2            ;set membase    (read)
  1843.         move.l    fib_Size(A3),D3        ;set filesize   (read)
  1844. ;-----------------------------------------------
  1845.         move.l    D3,D0            ;get filesize
  1846.         addq.l    #2,D0            ;need one linefeed +
  1847.                         ;null terminator at eof
  1848.         addq.l    #3,D0            ;get long aligned
  1849.         andi.b    #-4,D0            ;get long aligned
  1850.  
  1851.         move.l    #"EOF!",0(A2,D0.l)    ;set security ID
  1852. ;-----------------------------------------------
  1853.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  1854.         jsr    _LVORead(A6)        ;use DOS to (read) bytes
  1855.         cmp.l    D0,D3            ;test for success
  1856.         bne    Error2            ;branch if fail (free mem)
  1857. ;----------------------------------------------------------------------------
  1858.         moveq    #10,D0            ;get linefeed
  1859.         lea    -1(A2,D3.l),A0        ;jump to eof
  1860.         cmp.b    (A0)+,D0        ;check for linefeed
  1861.         beq.b    .skip            ;branch if set
  1862.  
  1863.         move.b    D0,(A0)+        ;add a linefeed at eof
  1864.  
  1865. .skip        clr.b    (A0)            ;set eof_terminator
  1866.  
  1867. *********************************************** close indexfile *************
  1868.  
  1869. CloseIFile    move.l    IHandle(A5),D1        ;set filehandle
  1870.         beq.b    .skip
  1871.  
  1872.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  1873.         jsr    _LVOClose(A6)        ;use DOS to (close) file
  1874.  
  1875.         moveq    #0,D0            ;clear filehandle
  1876.         move.l    D0,IHandle(A5)
  1877.  
  1878. .skip        rts                ;go back
  1879.  
  1880. *****************************************************************************
  1881.  
  1882.         cnop    0,4
  1883.  
  1884. *********************************************** free memory (indexfile) *****
  1885.  
  1886. FreeMemA    move.l    MemoryA(A5),D1        ;get file memory
  1887.         beq.b    .skip            ;branch if not set
  1888.  
  1889.         movea.l    D1,A1            ;set memory base
  1890.         lea    (A5),A0            ;get fileinfoblock
  1891.         move.l    fib_Size(A0),D0        ;set filesize
  1892.  
  1893.         addq.l    #2,D0            ;need one linefeed +
  1894.                         ;null terminator at eof
  1895.  
  1896.         addq.l    #3,D0            ;get long aligned
  1897.         andi.b    #-4,D0            ;get long aligned
  1898.  
  1899.         addq.l    #4,D0            ;add room for security ID
  1900.  
  1901.         movea.l    4.w,A6            ;set EXEC to call a function
  1902.         jsr    _LVOFreeMem(A6)        ;use EXEC to (freemem)
  1903.  
  1904.         moveq    #0,D0            ;clear buffer
  1905.         move.l    D0,MemoryA(A5)
  1906.  
  1907. .skip        rts                ;go back
  1908.  
  1909. *****************************************************************************
  1910.  
  1911.         cnop    0,4
  1912.  
  1913. *********************************************** free memory (indexlist) *****
  1914.  
  1915. FreeEList    move.l    EList(A5),D1        ;get elist memory
  1916.         beq.b    .skip            ;branch if not set
  1917.  
  1918.         movea.l    D1,A1            ;set memory base
  1919.  
  1920.         move.l    ELSize(A5),D0        ;set size
  1921.  
  1922.         movea.l    4.w,A6            ;set EXEC to call a function
  1923.         jsr    _LVOFreeMem(A6)        ;use EXEC to (freemem)
  1924.  
  1925.         moveq    #0,D0            ;clear buffer
  1926.         move.l    D0,EList(A5)
  1927.  
  1928. .skip        rts                ;go back
  1929.  
  1930. *****************************************************************************
  1931.  
  1932.         cnop    0,4
  1933.  
  1934. *********************************************** read user arguments *********
  1935.  
  1936. ReadArgs    lea    Template(pc),A1        ;get template
  1937.         lea    ArgArray(A5),A2        ;get arg_array
  1938.         move.l    A1,D1            ;set arg_template
  1939.         move.l    A2,D2            ;set array
  1940.         moveq    #0,D3            ;set args (unused)
  1941.         movea.l    DOSBase(A5),A6        ;set dos_base
  1942.         jsr    _LVOReadArgs(A6)    ;use dos to readargs
  1943.         move.l    D0,RDArgs(A5)        ;save returncode
  1944.         beq    Error2
  1945.         rts                ;else, go back
  1946.  
  1947. *****************************************************************************
  1948.  
  1949. Template dc.b "INDEXFILE/A,OUTPUTFILE/A",0
  1950.      dc.b "WS=WRITESORTED/K,SKIP/N,C=CASE/S,R=REVERSE/S,S=SLOW/S",0
  1951. Header     dc.b "ERROR",0
  1952.  
  1953. *****************************************************************************
  1954.  
  1955.         cnop    0,4
  1956.  
  1957. *****************************************************************************
  1958.  
  1959. ChkArgs        moveq    #115,D1            ;preset errorcode "bad num.."
  1960.  
  1961.         move.l    SkipHead(A5),D0        ;get "SKIP/N" ptr.
  1962.         beq.b    .skip            ;branch if not set
  1963.  
  1964.         movea.l    D0,A0            ;set buffer
  1965.         tst.l    (A0)            ;check for wrong number
  1966.         bmi.b    Error1            ;branch if so
  1967.  
  1968. .skip        moveq    #116,D1            ;preset errorcode "wrong arg"
  1969.  
  1970.         move.l    OutputFile(A5),d0    ;one of both ptr. must set
  1971.         or.l    SortedFile(A5),D0
  1972.         beq.b    Error1            ;branch if not
  1973.  
  1974.         rts                ;go back
  1975.  
  1976. *****************************************************************************
  1977.  
  1978.         cnop    0,4
  1979.  
  1980. ************************************************ free argument buffer *******
  1981.  
  1982. FreeArgs    move.l    RDArgs(A5),D1        ;get arg_structure
  1983.         beq.b    .skip            ;branch if not set
  1984.  
  1985.         move.l    DOSBase(A5),A6        ;set dos_base
  1986.         jsr    _LVOFreeArgs(A6)    ;use dos to freeargs
  1987.  
  1988.         moveq    #0,D0            ;clear buffer
  1989.         move.l    D0,RDArgs(A5)
  1990.  
  1991. .skip        rts                ;go back
  1992.  
  1993. *****************************************************************************
  1994.  
  1995.         cnop    0,4
  1996.  
  1997. *********************************************** print error information *****
  1998.  
  1999. Error3        move.w    #304,D1            ;set errorcode "***Break"
  2000.         ext.l    D1            ;clear highword
  2001.         bra.b    Error1
  2002.  
  2003. Error2        moveq    #0,D1            ;get errorcode by dos
  2004.  
  2005. Error1        addq    #4,SP            ;clear return_address
  2006.         move.l    D1,RCode2(A5)        ;set errorcode
  2007.         pea    Quit(pc)        ;set return_address
  2008.  
  2009. Error0        move.l    RCode2(A5),D1        ;get errorcode
  2010.         bne.b    .skip            ;branch if known!
  2011.  
  2012.         movea.l    DOSBase(A5),A6        ;set dos to call a function
  2013.         jsr    _LVOIoErr(A6)        ;use dos to get (ioerr)
  2014.  
  2015.         move.l    D0,D1            ;get errorcode
  2016.         move.l    D1,RCode2(A5)        ;set errorcode
  2017.  
  2018. .skip        movea.l    DOSBase(A5),A6        ;set dos_base
  2019.         jsr    _LVOSetIoErr(A6)    ;use dos to set pr_result2
  2020.  
  2021.         move.l    RCode2(A5),D1        ;get errorcode
  2022.         moveq    #0,D2            ;prepare dos printfault
  2023.  
  2024.         cmp.w    #304,D1            ;check for break by user
  2025.         beq.b    .PrintFault        ;branch if so
  2026.  
  2027.         lea    Header(pc),A2        ;get head_text 'ERROR:'
  2028.         move.l    A2,D2            ;set header
  2029.  
  2030. .PrintFault    jsr    _LVOPrintFault(A6)    ;use dos to printfault
  2031.  
  2032.         moveq    #5,D0            ;set returncode rc=warn
  2033.         move.l    D0,RCode1(A5)        ;save
  2034.         rts                ;go back
  2035.  
  2036. *****************************************************************************
  2037.  
  2038.         ifd    BSS_Section
  2039.  
  2040.         SECTION    ChkIndex_bss,BSS
  2041.  
  2042.         elseif
  2043.  
  2044.         cnop    0,4
  2045.  
  2046.         endc
  2047.  
  2048. *****************************************************************************
  2049.  
  2050. DataBase    ds.b    BSS_Size
  2051.  
  2052.  end of source **************************************************************
  2053.